package cn.golxen.blog.commons.utils;

import cn.golxen.blog.entity.Essay;
import cn.golxen.blog.exception.exceptionClass.GetEssayEmptyException;
import com.alibaba.fastjson.JSONObject;

import java.util.HashSet;
import java.util.Set;

public class JSONUtils {

    public static Set<Essay> JSONSetToEssaySet(Set<String> JSONStrSet){
        Set<Essay> set=new HashSet<>();
        JSONStrSet.forEach((value)->{
            if (value.equals("空"))
                throw new GetEssayEmptyException();
            set.add(JSONObject.parseObject(value,Essay.class));
        });
        return set;
    }
}
